<script setup>
import VueNextAddressPicker from "vue-next-address-picker"
import { ref, watchEffect } from "vue"
import { userStore } from '../store/index'
import { fetchApi } from '../apis/fetchapi'
import { getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance();
import GoBack from '../components/GoBack.vue'
const userSData = userStore();

const userInfo = ref({ ...userSData.userInfo, suggestion: '' })
const feedbackStatus = ref(false)
function confirmSuggest() {
  if (userInfo.value.suggestion === '') {
    proxy.$toast({
      value: '请填写反馈内容',
      type: 'fail'
    })
    return false;
  }

  const url = '/suggestion';

  fetchApi(url, { suggestion: userInfo.value.suggestion }).then(res => {
    console.log(res)
    if (res.code === 200) {
      feedbackStatus.value = true;
    } else {
      proxy.$toast({
        value: res.msg,
      })
    }
  })

}


</script>
<template>
  <div class="edit-address">
    <GoBack title="我的信息"></GoBack>
    <div class="edit-con">
      <div class="edit-li">
        <div class="span">店铺名称</div>
        <div class="r"><input type="text" placeholder="请输入店铺名称" v-model="userInfo.shopName" readonly></div>
      </div>
      <div class="edit-li">
        <div class="span">所属体系</div>
        <div class="r"><input type="text" placeholder="所属体系" v-model="userInfo.schemeType" readonly></div>
      </div>
      <div class="edit-li">
        <div class="span">联系人</div>
        <div class="r"><input type="text" placeholder="请输入联系人" v-model="userInfo.connectName" readonly></div>
      </div>
      <div class="edit-li">
        <div class="span">联系电话</div>
        <div class="r"><input type="text" placeholder="请输入联系电话" v-model="userInfo.connectPhone" readonly></div>
      </div>
      <div class="edit-li">
        <div class="span-l"><i>*</i>反馈内容</div>
        <div class="l-r">
          <textarea type="text" placeholder="请输入反馈内容" v-model="userInfo.suggestion"></textarea>
        </div>
      </div>
      <div class="confirm" @click="confirmSuggest">确认提交</div>
      <div class="feedback-win" v-show="feedbackStatus">
        <div class="feedback-success">
          <p>感谢您的反馈提交</p>
          <div @click="feedbackStatus = false">确认</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.edit-address {
  width: 100%;
  height: 100vh;

  .edit-con {
    width: 100%;
    height: calc(100vh - 75px - 54px);
    background: rgb(243, 243, 243);
    margin-top: 10px;
    position: relative;
    overflow: auto;
    padding-bottom: 50px;
  }

  .edit-li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    background-color: #ffffff;
    box-sizing: border-box;
    flex-wrap: wrap;
    position: relative;
    border-bottom: 1PX solid rgb(187, 187, 187);

    .span {
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      color: rgb(16, 16, 16);

      i {
        padding-right: 4px;
        color: red;
      }
    }

    input {
      width: 200px;
      text-align: right;
      height: 30px;
      line-height: 30px;
      color: rgb(16, 16, 16);
      font-size: 14px;
    }

    .span-l {
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      color: rgb(16, 16, 16);

      i {
        padding-right: 4px;
        color: red;
      }
    }

    .l-r {
      width: 250px;
      position: relative;

      textarea {
        width: 100%;
        display: block;
        height: 110px;
        color: rgb(16, 16, 16);
        font-size: 14px;
        text-align: left;
        border: 1PX solid #cccccc;
        box-sizing: border-box;
        padding: 7px;
      }

    }



  }

  .warning {
    width: 340px;
    text-align: left;
    line-height: 20px;
    font-size: 14px;
    margin: 20px auto 40px;
  }

  .confirm {
    width: 348px;
    height: 46px;
    font-size: 14px;
    box-sizing: border-box;
    border: 1PX solid rgb(187, 187, 187);
    text-align: center;
    background: #ffffff;
    font-size: 16px;
    color: rgb(97, 97, 97);
    margin: 50px auto;
    line-height: 44px;
    cursor: pointer;
    border-radius: 4px;
  }

  .choose-area {
    width: 200px;
    text-align: right;
    height: 30px;
    line-height: 30px;
    color: #b9b9b9;
    font-size: 14px;

    &.check {
      color: #4f4f4f;
    }
  }

  .choose-con {
    position: absolute;
    top: 124px;
    left: 0;
    width: 100%;
    background: #333;
    z-index: 2;
  }

  .feedback-win {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;

    .feedback-success {
      width: 282px;
      height: 229px;
      font-size: 12px;
      background: rgb(255, 255, 255);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
    }

    p {
      color: rgba(64, 149, 229, 1);
      font-size: 16px;
      font-weight: bold;
      line-height: 25px;
      margin-bottom: 55px;
    }

    div {
      border-radius: 4px;
      font-size: 14px;
      line-height: 30px;
      width: 80px;
      height: 30px;
      color: rgb(255, 255, 255);
      background: rgb(64, 149, 229);
      text-align: center;
    }
  }

}
</style>
